/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import javax.swing.JOptionPane;
import src.ClaseCargo;
import src.Core;
import src.LinkedLists;

/**
 *
 * @author Strauzen
 */
public class VentanaCargo extends javax.swing.JFrame {

    Ventana1 v1;
    Ventana3 v3;
    VentanaPersonaje vp;
    ClaseCargo CC;
    
    /**
     * Creates new form VentanaCargo
     */
    public VentanaCargo(Ventana1 v1, Ventana3 v3, VentanaPersonaje vp,ClaseCargo CC) {
        this.CC = CC;
        this.v1 = v1;
        this.v3 = v3;
        this.vp = vp;
        initComponents();
    }

    private boolean comprobar(){
        String mensaje = "";
        boolean resultado = false;
        
        if (this.jTextField_vcNombre.getText().equals(""))
            mensaje += "Por favor rellene el campo de nombre\n\n";
        if (this.jTextField_vcDescripcion.getText().equals(""))
            mensaje += "Por favor rellene el campo de descripción\n\n";
 
        if ("".equals(mensaje))
            resultado =true;
        else
            JOptionPane.showMessageDialog(null, mensaje);
        
        return resultado;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTextField_vcNombre = new javax.swing.JTextField();
        jLabel_vcNombre = new javax.swing.JLabel();
        jLabel_vcDescripcion = new javax.swing.JLabel();
        jTextField_vcDescripcion = new javax.swing.JTextField();
        jButton_vcFichero = new javax.swing.JButton();
        jButton_vcTerminar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Añadir Cargo");
        setName("Añadir Cargo"); // NOI18N

        jLabel_vcNombre.setText("Nombre");

        jLabel_vcDescripcion.setText("Descripcion");

        jButton_vcFichero.setText("Añadir Fichero");
        jButton_vcFichero.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_vcFicheroMouseClicked(evt);
            }
        });

        jButton_vcTerminar.setText("Terminar");
        jButton_vcTerminar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_vcTerminarMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel_vcNombre)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField_vcNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel_vcDescripcion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField_vcDescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(0, 279, Short.MAX_VALUE)
                .addComponent(jButton_vcFichero))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(149, 149, 149)
                .addComponent(jButton_vcTerminar)
                .addContainerGap(156, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_vcNombre)
                    .addComponent(jTextField_vcNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_vcDescripcion)
                    .addComponent(jTextField_vcDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton_vcFichero)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton_vcTerminar))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_vcTerminarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_vcTerminarMouseClicked
        // TODO add your handling code here:
        if(comprobar()){
            this.setVisible(false);
            vp.setVisible(true);
            CC.setIdCargo(Core.CrearCargo(jTextField_vcNombre.getText(), jTextField_vcDescripcion.getText()));
            LinkedLists.anadeCargoParaPersonajes(CC);
            this.dispose();
        }
    }//GEN-LAST:event_jButton_vcTerminarMouseClicked

    private void jButton_vcFicheroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_vcFicheroMouseClicked
        // TODO add your handling code here:

            this.setVisible(false);
            Ventana4 v4 = new Ventana4(v1,v3);
            v4.setVisible(true);
            v4.setPadre(5);
            v4.setVca(this);
    }//GEN-LAST:event_jButton_vcFicheroMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_vcFichero;
    private javax.swing.JButton jButton_vcTerminar;
    private javax.swing.JLabel jLabel_vcDescripcion;
    private javax.swing.JLabel jLabel_vcNombre;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField_vcDescripcion;
    private javax.swing.JTextField jTextField_vcNombre;
    // End of variables declaration//GEN-END:variables
}
